package org.example.Controller;

import cn.hutool.core.util.IdUtil;
import jakarta.annotation.Resource;
import org.example.common.Result;
import org.example.pojo.Order;
import org.example.pojo.OrderTO;
import org.example.pojo.Query;
import org.example.service.OrderService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("order")
public class OrderController {
    @Resource
    private OrderService orderService;
    @PostMapping("/add")
    public Result add(@RequestBody OrderTO orderTO){
        Result result=orderService.add(orderTO);

        return Result.ok(result);
    }
    @PostMapping("/all")
    public Result all(String status,Integer userId){

      Result result= orderService.getall(status,userId);
      return result;

     }
     @PostMapping("/update")
    public Result update(@RequestBody Order order){
        Result result=orderService.updateorder(order);
        return result;
     }
     @PostMapping("/delete")
    public Result delete( Integer id){
        Result result=orderService.shanchu(id);
        return result;
     }
     @PostMapping("/detail")
    public Result detail(Integer id){
        Result result=orderService.detail(id);
        return result;

     }
     @PostMapping("/list")
    public Result list(@RequestBody Query query){
        Result result=orderService.selectpage(query);
        return result;

     }
}
